<?php
@session_start();
include_once dirname(__FILE__)."/../../model/config.php";
		$_unite=new unite();


	$constraint='';
	$limit=0;
	$start=0;
	$pagination='';
	if(isset($_POST["code_ue"]) && !empty($_POST["code_ue"])){
		$constraint.=" AND code_ue='".$_POST["code_ue"]."'";
	}

	if(isset($_POST["lib_unite"]) && !empty($_POST["lib_unite"])){
		$constraint.=" AND lib_unite='".$_POST["lib_unite"]."'";
	}

	if(isset($_POST["nature_unite"]) && !empty($_POST["nature_unite"])){
		$constraint.=" AND nature_unite='".$_POST["nature_unite"]."'";
	}

	if(isset($_POST["ECUE"]) && !empty($_POST["ECUE"])){
		$constraint.=" AND ECUE='".$_POST["ECUE"]."'";
	}

	if(isset($_POST["volume_cours"]) && !empty($_POST["volume_cours"])){
		$constraint.=" AND volume_cours='".$_POST["volume_cours"]."'";
	}

	if(isset($_POST["volume_TP"]) && !empty($_POST["volume_TP"])){
		$constraint.=" AND volume_TP='".$_POST["volume_TP"]."'";
	}

	if(isset($_POST["volume_TD"]) && !empty($_POST["volume_TD"])){
		$constraint.=" AND volume_TD='".$_POST["volume_TD"]."'";
	}

	if(isset($_POST["coeifficient"]) && !empty($_POST["coeifficient"])){
		$constraint.=" AND coeifficient='".$_POST["coeifficient"]."'";
	}

	if(isset($_POST["code_diplome"]) && !empty($_POST["code_diplome"])){
		$constraint.=" AND code_diplome='".$_POST["code_diplome"]."'";
	}

	if(isset($_POST["code_niveau"]) && !empty($_POST["code_niveau"])){
		$constraint.=" AND code_niveau='".$_POST["code_niveau"]."'";
	}

	if(isset($_POST["code_domaine"]) && !empty($_POST["code_domaine"])){
		$constraint.=" AND code_domaine='".$_POST["code_domaine"]."'";
	}

	if(isset($_POST["date_soumission"]) && !empty($_POST["date_soumission"])){
		$constraint.=" AND date_soumission='".$_POST["date_soumission"]."'";
	}

	if(isset($_POST["credit"]) && !empty($_POST["credit"])){
		$constraint.=" AND credit='".$_POST["credit"]."'";
	}

	if(isset($_POST["projet"]) && !empty($_POST["projet"])){
		$constraint.=" AND projet='".$_POST["projet"]."'";
	}

	

	if(isset($_POST["date_depot_contenu"]) && !empty($_POST["date_depot_contenu"])){
		$constraint.=" AND date_depot_contenu='".$_POST["date_depot_contenu"]."'";
	}

	if(isset($_POST["code_mention"]) && !empty($_POST["code_mention"])){
		$constraint.=" AND code_mention='".$_POST["code_mention"]."'";
	}

	if(isset($_POST["specialite"]) && !empty($_POST["specialite"])){
		$constraint.=" AND specialite='".$_POST["specialite"]."'";
	}

	if(isset($_POST["session"]) && !empty($_POST["session"])){
		$constraint.=" AND session='".$_POST["session"]."'";
	}

	if(isset($_POST["date_decision"]) && !empty($_POST["date_decision"])){
		$constraint.=" AND date_decision='".$_POST["date_decision"]."'";
	}

	if(isset($_POST["decision"]) && !empty($_POST["decision"])){
		$constraint.=" AND decision='".$_POST["decision"]."'";
	}

	if(isset($_POST["observation_ue"]) && !empty($_POST["observation_ue"])){
		$constraint.=" AND observation_ue='".$_POST["observation_ue"]."'";
	}

	if(isset($_POST["mail_sended"]) && !empty($_POST["mail_sended"])){
		$constraint.=" AND mail_sended='".$_POST["mail_sended"]."'";
	}

	if(isset($_POST["nbr_ens"]) && !empty($_POST["nbr_ens"])){
		$constraint.=" AND nbr_ens='".$_POST["nbr_ens"]."'";
	}

	if(isset($_POST["decision_production"]) && !empty($_POST["decision_production"])){
		$constraint.=" AND decision_production='".$_POST["decision_production"]."'";
	}

	if(isset($_POST["date_decision_num"]) && !empty($_POST["date_decision_num"])){
		$constraint.=" AND date_decision_num='".$_POST["date_decision_num"]."'";
	}

	if(isset($_POST["date_decision_exp"]) && !empty($_POST["date_decision_exp"])){
		$constraint.=" AND date_decision_exp='".$_POST["date_decision_exp"]."'";
	}

	if(isset($_POST["duree"]) && !empty($_POST["duree"])){
		$constraint.=" AND duree='".$_POST["duree"]."'";
	}

	if(isset($_POST["delai_jour"]) && !empty($_POST["delai_jour"])){
		$constraint.=" AND delai_jour='".$_POST["delai_jour"]."'";
	}

	if(isset($_POST["validation_scientifique"]) && !empty($_POST["validation_scientifique"])){
		$constraint.=" AND validation_scientifique='".$_POST["validation_scientifique"]."'";
	}

	if(isset($_POST["expRPL"]) && !empty($_POST["expRPL"])){
		$constraint.=" AND expRPL='".$_POST["expRPL"]."'";
	}

	if(isset($_POST["expMoodle"]) && !empty($_POST["expMoodle"])){
		$constraint.=" AND expMoodle='".$_POST["expMoodle"]."'";
	}
	if(isset($_POST["etat_soumission"]) && !empty($_POST["etat_soumission"])){
		$constraint.=" AND etat_soumission='".$_POST["etat_soumission"]."'";
	}
	
	
	
	

	if(isset($_POST['limit'])){$limit=$_POST['limit'];}
	if(isset($_POST['start'])){$start=$_POST['start'];}
	if($limit>0){
		$pagination.=" LIMIT  $start,$limit"; 
   }
	 if(isset($_SESSION["cin"]) && !empty($_SESSION["cin"])){
		$constraint.=" AND CIN='".$_SESSION['cin']."'";
	}
	   $constraint.=" AND etat_soumission='1'";
	
		$res=$_unite->SELECT($constraint,$pagination); 

		 $data=array();
		  while($row=$_unite->fetch_object()){
		  	$data[]=$row;
	  	  }
  	 	 $count=$_unite->countRowInTable();
		
	   if($res!="success"){
		echo json_encode(array('success' => 'false','result' => "$res" ));
	  }else{
	  	echo json_encode(array('totalcount' => $count,'result' => $data ));
	  	
	  }
?>